* ======================================
* --------- Network Immigrants ---------
* ======================================


	use "$dta\ImportPers.dta", clear
	keep if immigrant == 1
	
	* Occupation
	merge 1:1 idPers using $dta\ImportOccup15.dta, nogen keep(master matched)
	keep idPers immigrant birthcountry occupation2015

	
* Imm1net (narrow)
* ================	

	preserve
	keep if occupation2015 != ""
	gen occupation3 = substr(occupation2015, 1, 3)	
	egen Imm1net = group(occupation3 birthcountry) 
	gen Imm1 = 1

	keep idPers Imm1 Imm1net
	save $dta\NetworkImm1.dta, replace
	
	restore
	
	
* Imm2net (broad)
* ===============	

	preserve
	keep if occupation2015 != ""
	gen occupation2 = substr(occupation2015, 1, 2)
	egen Imm2net = group(occupation2 birthcountry)
	gen Imm2 = 1
	
	keep idPers Imm2 Imm2net
	save $dta\NetworkImm2.dta, replace
	
	restore
	
	
* Imm3aNet (birthcountry only)
* ============================

	preserve
	egen Imm3anet = group(birthcountry)	
	gen Imm3a = 1
	
	keep idPers Imm3a Imm3anet
	save $dta\NetworkImm3a.dta, replace
	restore
	
	
* Imm3bNet (occupation only)
* ==========================

	preserve
	keep if occupation2015 != ""
	gen occupation3 = substr(occupation2015,1,3)
	egen Imm3bnet = group(occupation3)	
	gen Imm3b = 1
	
	keep idPers Imm3b Imm3bnet
	save $dta\NetworkImm3b.dta, replace
	restore
	